package edu.mtu.citizenscience.cs.sdk.uploader.model.entry;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import edu.mtu.citizenscience.cs.sdk.uploader.model.Entry;
import edu.mtu.citizenscience.cs.sdk.uploader.model.EntryType;
/**
 * @author Corbin Uselton <corbinu@cwuselto@mtu.edu>
 * @copyright (c) 2012 MichiganTech <http://www.mtu.edu>
 * @since 1.0
 * 
 * Entry of the type file
 */
public class FileEntry extends Entry<File> {
	// set the entry type as TYPE_FILE
	protected EntryType type = EntryType.TYPE_FILE;
	// the type of file in the entry
	private FileType fileType;
	// the path to the file on the server
	private String severPath;
	
	/**
	 * Create File Entry
	 * 
	 * @param   void
	 * @return	void
	 */
	public FileEntry() {  }
	
	/**
	 * Create File Entry
	 * 
	 * @param   name - String - the entry name
	 * @param   type - FileType - the file type
	 * @param   value - File - the entry file
	 * @return	void
	 */
	public FileEntry(String name, FileType type, File value)
	{
		super(name, EntryType.TYPE_FILE, value);
		
		this.fileType = type;
	}
	
	/**
	 * Get the entry file type
	 * 
	 * @param   void
	 * @return	FileType - the file type
	 */
	public FileType getFileType()
	{
		return this.fileType;
	}
	
	/**
	 * Set the entry file type
	 * 
	 * @param   type - FileType - the file type
	 * @return	void
	 */
	public void setFileType(FileType type)
	{
		this.fileType = type;
	}
	
	/**
	 * Get the server path to the file
	 * 
	 * @param   void
	 * @return	String - the path to the file on the server
	 */
	public String getSeverPath()
	{
		return this.severPath;
	}
	
	/**
	 * Set the server path to the file
	 * 
	 * @param   serverPath - String - the path to the file on the server
	 * @return	void
	 */
	public void setServerPath(String severPath)
	{
		this.severPath = severPath;
	}
	
	/**
	 * Entry type can not be set for the file entry
	 * 
	 * @param   type - FileType - the file type
	 * @return	void
	 */
	public void setType(EntryType type) {  }
	
	/**
	 * Get the file entry as map to upload to the server
	 * 
	 * @param   void
	 * @return	Map<String, Object> - File entry as a map
	 */
	public Map<String, Object> getAsMap()
	{
		// create a new map to store the file entry
		Map<String, Object> map = new HashMap<String, Object>();
		
		// put the file type in the map
		map.put("type", this.getFileType());
		// put the path to the file on the server in the map
		map.put("path", this.getSeverPath());
		
		// return the file map
		return map;
	}

}
